import request from '@/utils/request'
import QS from 'qs'
import { downFile } from '@/utils/request'

/**
 * 政策分页查询
 * @param {查询条件} data
 */
export function listLayPolicy(query) {
  return request({
    url: 'business/LayPolicy/list',
    method: 'get',
    params: query,
    paramsSerializer: function (params) {
      return QS.stringify(params, { indices: false })
    }
  })
}

/**
 * 政策tree查询
 * @param {查询条件} data
 */
export function treelistLayPolicy(query) {
  return request({
    url: 'business/LayPolicy/treelist',
    method: 'get',
    params: query,
  })
}
/**
 * 新增政策
 * @param data
 */
export function addLayPolicy(data) {
  return request({
    url: 'business/LayPolicy',
    method: 'post',
    data: data,
  })
}
/**
 * 修改政策
 * @param data
 */
export function updateLayPolicy(data) {
  return request({
    url: 'business/LayPolicy',
    method: 'PUT',
    data: data,
  })
}
/**
 * 获取政策详情
 * @param {Id}
 */
export function getLayPolicy(id) {
  return request({
    url: 'business/LayPolicy/' + id,
    method: 'get'
  })
}

/**
 * 删除政策
 * @param {主键} pid
 */
export function delLayPolicy(pid) {
  return request({
    url: 'business/LayPolicy/delete/' + pid,
    method: 'POST'
  })
}
// 导出政策
export async function exportLayPolicy(query) {
  await downFile('business/LayPolicy/export', { ...query })
}
